<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.rawgit.com/konvajs/konva/1.4.0/konva.min.js"></script>
  <meta charset="utf-8">
  <title>Konva Shape Caching Demo</title>
  <style>
    body {
      margin: 0;
      padding: 0;
      overflow: hidden;
      background-color: #F0F0F0;
    }
  </style>
</head>
<body>
  <div id="container"></div>
  <script>
    var width = window.innerWidth;
    var height = window.innerHeight;

    var stage = new Konva.Stage({
      container: 'container',
      width: width,
      height: height
    });
    
    var layer = new Konva.Layer();
    
    var star = new Konva.Star({
      innerRadius: 20,
      outerRadius: 50,
      fill: 'red',
      stroke: 'black',
      strokeWidth: 5,
      numPoints: 5,
      x: 60,
      y: 60,
      draggable: true,
      shadowOffset: { x : 5, y : 5},
      shadowColor: 'black',
      shadowBlur: 5,
      shadowOpacity: 0.5
    });
    
    layer.add(star);
    stage.add(layer);
    star.cache();
    
    var clone;
    for(var n = 0; n < 10; n++) {
      clone = star.clone({
        x: Math.random() * stage.getWidth(),
        y: Math.random() * stage.getHeight()
      });
      clone.cache();
      layer.add(clone);
    }
    
    layer.draw();
  </script>

</body>
</html>
